<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>选择计量单位</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link rel="shortcut icon" th:href="@{/favicon.ico}">
    <link th:href="@{/css/bootstrap.min.css}" rel="stylesheet">
    <link th:href="@{/css/font-awesome.css}" rel="stylesheet">
    <link th:href="@{/css/animate.css}" rel="stylesheet">
    <link th:href="@{/css/style.css}" rel="stylesheet">
    <link th:href="@{/self/self-common.css}" rel="stylesheet">

    <link th:href="@{/css/plugins/bootstrap-table/bootstrap-table.min.css}" rel="stylesheet">
    <link th:href="@{/css/plugins/bootstrap-select/bootstrap-select.css}" rel="stylesheet">

    <!-- Sweet Alert -->
    <link th:href="@{/css/plugins/sweetalert/sweetalert.css}" rel="stylesheet">
</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12 search-card">
            <div class="ibox">
                <div class="ibox-content">
                    <form class="form-inline">
                        <div class="form-group searchCX">
                            <input id="searchName" class="form-control" type="text" placeholder="请输入计量单位名称" clearable>
                        </div>
                        <div class="form-group">
                            <button id="btnSearch" class="btn btn-success" type="button" onclick="querySearch()">
                                <i class="fa fa-search"></i>
                                查询
                            </button>
                        </div>
                    </form>
                </div>
            </div>
        </div>

        <div class="col-sm-12 table-card">
            <div class="ibox ">
                <div class="ibox-title">
                    <h5>
                        <i class="fa fa-bookmark"></i>
                        计量单位列表
                    </h5>
                </div>
                <div class="ibox-content">
                    <table id="dataTable" data-mobile-responsive="true"></table>
                </div>
            </div>
        </div>
    </div>


</div>


<!-- 全局js -->
<script th:src="@{/js/jquery.min.js}"></script>
<script th:src="@{/js/bootstrap.min.js}"></script>
<script th:src="@{/js/content.js}"></script>
<script th:src="@{/js/app.js}" type="text/javascript"></script>

<!-- Bootstrap table -->
<script th:src="@{/js/plugins/bootstrap-table/bootstrap-table.min.js}"></script>
<script th:src="@{/js/plugins/bootstrap-table/bootstrap-table-mobile.min.js}"></script>
<script th:src="@{/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js}"></script>
<!--提示框-->
<script th:src="@{/js/plugins/layer/layer.min.js}"></script>
<!--下拉选择框-->
<script th:src="@{/js/plugins/bootstrap-select/bootstrap-select.js}"></script>
<!--日期-->
<script th:src="@{/js/plugins/layer/laydate/laydate.js}"></script>

<!--bootstrap导出-->
<script th:src="@{/js/plugins/bootstrap-table-export/bootstrap-table-export.js}"></script>
<script th:src="@{/js/plugins/bootstrap-table-export/tableExport.js}"></script>
<!--pdf导出 文本乱码问题-->
<script th:src="@{/js/plugins/bootstrap-table-export/pdfmake/pdfmake.min.js}"></script>
<script th:src="@{/js/plugins/bootstrap-table-export/pdfmake/gbsn00lp_fonts.js}"></script>
<!--将表导出为PDF文件-->
<script th:src="@{/js/plugins/bootstrap-table-export/pdfmake/jspdf.min.js}"></script>
<script th:src="@{/js/plugins/bootstrap-table-export/pdfmake/jspdf.plugin.autotable.js}"></script>

<script th:src="@{/js/plugins/sweetalert/sweetalert.min.js}"></script>

<script>

    var unitId = '';
    var unitName = '';

    function querySearch(){
        $('#dataTable').bootstrapTable('refresh');
    }

    $(document).ready(function () {
        function queryParams(params) {
            return {
                pageSize: params.pageSize,
                pageNumber: params.pageNumber,
                searchText: $("#searchName").val()
            }
        }
        $('#dataTable')
            .bootstrapTable({
                url: baseUrl + "getMeasureunitPage",
                method: "post",
                queryParamsType: "",
                queryParams: queryParams,
                pageNumber: 1,
                pageSize: 10,
                striped: true,
                cache: false,
                search: false,
                pagination: true,
                showRefresh: true,
                showToggle: true,
                showColumns: true,
                formatSearch: function () {
                    return "计量单位列表";
                },
                iconSize: 'outline',
                sidePagination: "server",
                showExport: false,
                buttonsAlign: "right",
                exportTypes: ['excel'],
                pageList: [10, 20, 30, 'all'],
                exportDataType: "basic",
                toolbar: '#toolbar',
                icons: {
                    refresh: 'glyphicon-repeat',
                    toggle: 'glyphicon-list-alt',
                    columns: 'glyphicon-list',
                    export: 'glyphicon-export'
                },
                exportOptions: {
                    ignoreColumn: [7],
                    fileName: '计量单位信息'
                }
                , responseHandler: function (res) {

                    var rows = [];
                    if (res.total !== 0) {
                        rows = res.list;
                    }
                    var result = {
                        rows: rows,
                        total: res.total
                    };
                    return result;
                },
                onEditableSave: function (field, row, oldValue, $ele) {


                },
                columns: [{
                    field: 'measureunit_sn',
                    title: '计量单位编号'
                }, {
                    field: 'measureunit_name',
                    title: '计量单位名称'
                },
                    {
                        field: 'user_name',
                        title: '创建人'
                    },
                    {
                        field: 'create_time',
                        title: '创建时间'
                    },
                    {
                        field: 'remarks',
                        title: '备注'
                    }
                ],
                onClickRow: function(row, $element) {
                    $('.info').removeClass('info');
                    $($element).addClass('info');
                    unitId = row.id;
                    unitName = row.measureunit_name;
                }
            });

    });


    var submit = function ()
    {
        if(unitId == "")
        {
            layer.msg("请选择一条计量单位信息");
            return '';
        }
        var param = {
            unitId: unitId,
            unitName:unitName
        };

        return JSON.stringify(param);
    }

</script>

</body>

</html>


